<template>
  <view class="change-record">
    <fui-card v-if="dataList" :margin="['32rpx', '25rpx']" :title="types[item.type]" :tag="item.createTime" v-for="item in dataList" :key="item.id">
          <view class="fui-card__content">
              <view class="money">
                 + {{(item.income / 100).toFixed(2)}}元
              </view>
          </view>
        </fui-card>
    <NoData v-else />
  </view>
</template>

<script setup lang="ts">
import NoData from "@/components/NoData/NoData.vue";
import dyUserPlayingService from "@/api/dyUserPlayingService";
const pageSize = ref(10)
const types = ref(['推广收益','团队收益'])
const pageNo = ref(1)
const dataList = ref()
const reachStatus = ref(true)
const getChangeRecord = async ()=>{

  if(reachStatus.value){
    uni.showLoading()
      const {success,result} = await dyUserPlayingService.changeRecord({
      pageSize:pageSize.value,
      pageNo:pageNo.value
    })
    if(success){
      dataList.value ?dataList.value = dataList.value.concat(result) : dataList.value = result 
      pageNo.value +=1;
      if(result.length < pageSize.value){
        reachStatus.value = false
      }
      uni.hideLoading()
    }
  }

}
onReachBottom(()=>{
  getChangeRecord()
})
onLoad(()=>{
  getChangeRecord()
})
</script>

<style lang="scss" scoped>
.change-record{
    padding: 28rpx;
    .fui-card__content{
      display: flex;
      padding: 28rpx;
      justify-content: space-between;
      .money{
        font-weight: bolder;
      }
      .status{
        font-size: 23rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100rpx;
        padding: 0 10rpx;
        color: white;
        border-radius: 8rpx;
      }
    }
}
</style>
